/* ponyedit.c */

#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <dirent.h>

#include "SDL.h"
#include "SDL_gfxPrimitives.h"

#include "ponyedit.h"
#include "graphics.h"
#include "pony.h"
#include "path.h"
#include "selection.h"
#include "dialog.h"
#include "list_dir.h"
#include "parse.h"
#include "map_area.h"
#include "maps.h"
#include "main_window.h"

static void read_bg_images(void)
{
  if (list_dir(DIR_BACKGROUNDS, ".png", bg_image_items, sizeof(bg_image_items)/sizeof(bg_image_items[0])) != 0) {
    printf("ERROR: can't list directory '%s'\n", DIR_BACKGROUNDS);
    exit(1);
  }
  if (bg_image_items[0] == NULL) {
    printf("ERROR: expecting at least one image in directory '%s'\n", DIR_BACKGROUNDS);
    exit(1);
  }
}

int main(int argc, char *argv[])
{
  read_bg_images();

  srand(time(NULL));
  init_video(1024, 768, 32, 0);
  load_images(bg_image_items[0]);
  
  SDL_EnableUNICODE(1);
  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

  sel_clear();

  dlg_run(&main_dialog, screen, 1);

  return 0;
}
